/**
 * Proyecto: Cognitum
 * Global IT Services 2008
 * @author Mislas
 */

Cognitum.Home = Ext.extend(Ext.Panel, {
    initComponent: function(){
        Ext.apply(this, {
            title: 'Home',
            anchor: '100% 100%',
            layout: 'hbox',
            layoutConfig: {
                align: 'stretch',
                pack: 'start'
            },
            defaultType: 'panel',
            defaults: {
                frame: false,
                border: false,
                autoScroll: true,
                defaultType: 'panel',
            },
            items: [{
                flex: 1,
                bodyStyle: 'padding: 10px 10px 10px 10px',
				layout: 'anchor',
                items: [{
                    frame: false,
                    border: false,
					anchor: '100% 10%',
					preventBodyReset: true,
					html: '<h2>Bienvenido a cognιтυм ' + Karma.Principal.Instance.getName() + '!!!</h2>'
				}, {
					xtype: 'msg.panel',
					anchor: '100%'
				}]
            }, {
                width: 270,
				xtype: 'notif.panel'
            }]
        });
        Cognitum.Home.superclass.initComponent.apply(this, arguments);
		
		var homeEntity = Karma.Core.ModuleManager.Instance.getEntity('PaginaInicio');
        homeEntity.useInvoker('Get', null, {
			fn: function(home) {
				this.items.get(0).insert(1, {
                    frame: false,
                    border: false,
					anchor: '100%, 55%',
					autoScroll: true,
					preventBodyReset: true,
					html: home.Code
				});
				this.doLayout();
			},
			scope: this
		});
    }
});

Ext.reg('homepage', Cognitum.Home);
